﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.User;
using CE.Global;
using CE.Provider;

public partial class provider_CarInsurance_ViewProviderCarDiscount : System.Web.UI.Page
{
    string PageName = "CXCI";
    string SubPageName = "CXCICDIS";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (!IsPostBack)
        {

        }

    }

 
    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/CarInsurance/TableMatching.aspx");
    }


    public string GetDiscountName(string discount)
    {
        string discountname = "Addtnal Named";

        if (discount == "Carrent")
        {
            discountname = "Car Rental Extension";
        }
        else if (discount == "Dealers")
        {
            discountname = "Dealer's W/Shop Extension";
        }
        else if (discount == "Loyalty")
        {
            discountname = "Loyalty";
        }
        else if (discount == "Moonroof")
        {
            discountname = "MoonRoof Extension";
        }
        else if (discount == "Multicars")
        {
            discountname = "Multi-cars";
        }
        else if (discount == "NCBP")
        {
            discountname = "NCBP Premium Loading";
        }
        else if (discount == "Offencefree")
        {
            discountname = "Offence-Free";
        }
        else if (discount== "Offpeak")
        {
            discountname = "OffPeak/Weekend";
        }
        else if (discount == "Restricted")
        {
            discountname = "Restricted Dr Condition";
        }
        else if (discount == "Sunroof")
        {
            discountname = "SunRoof Extension";
        }
        else if (discount == "Voluntary")
        {
            discountname = "Voluntary Excess";
        }

        return discountname;
    }

    public string GetDiscountType(string discount)
    {
        string discounttype = "Non Plus";

        if (discount == "Plus")
        {
            discounttype = "Plus";
        }

        return discounttype;
    }

    public string GetDescription(string discount)
    {
        string discountdesc = "Applicable";

        if (discount == "NA")
        {
            discountdesc = "Not Applicable";
        }
        else if (discount == "2nd")
        {
            discountdesc = "2nd Car Disc (5%)";
        }
        else if (discount == "3rd")
        {
            discountdesc = "3rd Car & Above Disc (10%)";
        }
        else if (discount == "500")
        {
            discountdesc = "S$500 Excess";
        }
        else if (discount == "1000")
        {
            discountdesc = "S$1000 Excess";
        }

        return discountdesc;
    }

    private void CheckMainPageAccess()
    {
        Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), PageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
    }

    private void CheckSubPageAccess()
    {
        Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), SubPageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
        else if (PageAccess == 100)
        {
            lnkNewClaimInfo.Visible = false;
        }
    }

}
